package main

import "fmt"

func main() {
	var info = map[int]string{
		110: "mike",
		111: "yoyo",
		112: "lily",
	}
	fmt.Println(info)
	//遍历map
	for i, v := range info {
		fmt.Println(i, v)
	}
	for _, v := range info {
		fmt.Println(v)
	}
	for k, _ := range info {
		fmt.Println(k)
	}
	for k := range info {
		fmt.Println(k)
	}
	//只是声明了一个map,没有初始化,为空(nil)map
	//不能 这么声明 var m1 map[int]string{}
	var m1 map[int]string
	fmt.Println(m1 == nil)
	//m1[1] = "mike" //err, panic:assignment to entry in nil map

	m2 := map[int]string{}
	m3 := make(map[int]string)
	m2[1] = "ab"
	fmt.Println(m2, m3)
	m4 := make(map[int]string, 10) //第2个参数指定容量
	fmt.Println(m4)

	value, ok1 := info[1]
	fmt.Println(value, ok1)
	value2, ok2 := info[111]
	fmt.Println(value2, ok2)

	//删除key
	delete(info, 110)
	fmt.Println(info)
}
